#pragma once
#include "PostProcessSystem.h"
 
class WPENGIN_API CRenderTargetChain:public ID3DDeviceStateDeposit,public Singleton<CRenderTargetChain> 
{
    friend  class  Singleton<CRenderTargetChain>; 
    friend class Singleton<CPostProcessSystem>;
    friend class  CPostProcessSystem;
	int m_nNext;
	bool m_bFirstRender;
	LPDIRECT3DTEXTURE9  m_pRenderTargetTexture[2];
	LPDIRECT3DSURFACE9 m_pRenderTargetSurface[2];
 
	CRenderTargetChain(void);
	~CRenderTargetChain(void);
	 
	void                Flip()
	{
		m_nNext = 1 - m_nNext;
	};
	LPDIRECT3DTEXTURE9  GetPrevTargetTexture()
	{
		return m_pRenderTargetTexture[1 - m_nNext];
	}

	LPDIRECT3DTEXTURE9  GetNextTargetTexture()
	{
		return m_pRenderTargetTexture[m_nNext];
	}
	LPDIRECT3DSURFACE9 GetPrevTargetSurface()
	{
			return m_pRenderTargetSurface[1-m_nNext];
	}
	LPDIRECT3DSURFACE9 GetNextTargetSurface()
	{
			return m_pRenderTargetSurface[m_nNext];
	}



	virtual void OnD3D9DestroyDevice();

	virtual HRESULT OnD3D9ResetDevice( IDirect3DDevice9* pd3dDevice );

	virtual void OnD3D9LostDevice();

	virtual HRESULT OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice );

 

};

